package com.file;


import java.io.File;
import java.io.FilenameFilter;
import java.io.IOException;
import java.lang.reflect.Field;
import java.util.Date;

/**
 * File 文件类
 */
public class 文件类 {
    public static void main(String[] args) {
        System.out.println(String.format("系统默认编码:%s",System.getProperty("file.encoding")));
        String path = "D:\\7788";
        File file =  new File(path);
        System.out.println(String.format("可读：%s，可写:%s,可删除：%s,存在：%s,路径：%s,名称：%s,父路径：%s,绝对路径:%s,普通文件:%s,最后修改:%s,长度：%s,列表：%s,创建:%s,再创建:%s,",
                file.canRead(),file.canWrite(),file.delete(),file.exists(),file.getAbsolutePath(),file.getName(),file.getParent(),file.isAbsolute(),file.isDirectory(),file.isFile(),new Date(file.lastModified()),file.length(),file.list(),file.mkdir(),file.mkdirs()));
        path  = "d:\\7788\\fuck\\sister.txt";
        file = new File(path);
        try {
            file.createNewFile();
        } catch (Exception e) {
            e.printStackTrace();
        }
            file.delete();
        System.out.println(File.separator);
        path=String.format("D:%s7788",File.separator);
        file = new File(path);
        FilenameFilter filter = new FilenameFilter() {
            @Override
            public boolean accept(File dir, String name) {
                return name.endsWith(".txt");
            }
        };
        String[] f = file.list(filter);
        for(String s:f){
            System.out.println(String.format("文件名：%s",s));
        }
    }
}
